Crate google_drive[][src]

Expand description

A rust library for interacting with the Google Drive v3 API.

For more information, the Google Drive v3 API is documented at developers.google.com/drive/api/v3/reference.

Example:

use std::env;

use google_drive::GoogleDrive;
use yup_oauth2::{read_service_account_key, ServiceAccountAuthenticator};

async fn get_drives() {
    // Get the GSuite credentials file.
    let gsuite_credential_file = env::var("GADMIN_CREDENTIAL_FILE").unwrap();
    let gsuite_subject = env::var("GADMIN_SUBJECT").unwrap();
    let gsuite_secret = read_service_account_key(gsuite_credential_file).await.expect("failed to read gsuite credential file");
    let auth = ServiceAccountAuthenticator::builder(gsuite_secret)
        .subject(gsuite_subject.to_string())
        .build()
        .await
        .expect("failed to create authenticator");

    // Add the scopes to the secret and get the token.
    let token = auth.token(&["https://www.googleapis.com/auth/drive"]).await.expect("failed to get token");

    if token.as_str().is_empty() {
        panic!("empty token is not valid");
    }

    // Initialize the Google Drive client.
    let drive_client = GoogleDrive::new(token.as_str().to_string());

    // List drives.
    let drives = drive_client.list_drives().await.unwrap();

    // Iterate over the drives.
    for drive in drives {
        println!("{:?}", drive);
    }
}

Structs

Error type returned by our library.

A drive.

An image file and cropping parameters from which a background image for this shared drive is set. This is a write only field; it can only be set on drive.drives.update requests that don’t set themeId. When specified, all fields of the backgroundImageFile must be set.

Capabilities the current user has on this shared drive.

A set of restrictions that apply to this shared drive or items inside this shared drive.

A file.

Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take.

Additional information about the content of the file. These fields are never populated in responses.

A thumbnail for the file. This will only be used if Google Drive cannot generate a standard thumbnail.

Additional metadata about image media, if available.

Geographic location information stored in the image.

Additional metadata about video media. This may not be available immediately upon upload.

Entrypoint for interacting with the Google Drive API.

A permission for a file. A permission grants a user, group, domain or the world access to a file or a folder hierarchy.

Details of whether the permissions on this shared drive item are inherited or directly on this item. This is an output-only field which is present only for shared drive items.

Deprecated - use permissionDetails instead.

An image file and cropping parameters from which a background image for this Team Drive is set. This is a write only field; it can only be set on drive.teamdrives.update requests that don’t set themeId. When specified, all fields of the backgroundImageFile must be set.

Capabilities the current user has on this Team Drive.

Information about a Drive user.